package com.swm.util;

public class HTMLManager {
	static HTMLManager 	htmlMgr  = null;
	
	public static HTMLManager getInstance()
	{
		if ( htmlMgr == null ){
			htmlMgr = new HTMLManager();	
		}
		return htmlMgr;
	}
	
	public boolean isNestedTag( String content, String tag )
	{
		String startTag = "<"  + tag + ">";
		String endTag 	= "</" + tag + ">";
		int refCount 	= 0;
		
		for ( int i = 0 ; i < content.length()-endTag.length() ; i++ )
		{
			char c = content.charAt(i);
			if ( startTag.equals( content.substring( i, i+startTag.length() )))
			{
				refCount++;
			}
			else if ( endTag.equals( content.substring( i, i+endTag.length() )))
			{
				refCount--;
			}
			
			if ( refCount > 1 )
				return true;
			
		}
		return false;
	}
}
